package com.yao.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.yao.AppConfig;
import com.yao.R;
import com.yao.image.GlideUtil;
import com.yao.presenter.bean.IndexDataBean;

import java.util.ArrayList;

public class IndexAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {

    public IndexAdapter() {
        super(new ArrayList<>());
        addItemType(AppConfig.ItemType.ITEMTYPE_INDEX_TITLE, R.layout.item_index_title);
        addItemType(AppConfig.ItemType.ITEMTYPE_INDEX, R.layout.item_index);
        addItemType(AppConfig.ItemType.ITEMTYPE_BOTTOM, R.layout.view_footer);
    }

    @Override
    protected void convert(BaseViewHolder helper, MultiItemEntity item) {
        if (item.getItemType() == AppConfig.ItemType.ITEMTYPE_INDEX) {
            IndexDataBean.ChildrenBean bean = (IndexDataBean.ChildrenBean) item;
            GlideUtil.loadImage(helper.getView(R.id.iv_index), bean.getAppLogo());
            helper.setText(R.id.tv_index, bean.getAppName());
        } else if (item.getItemType() == AppConfig.ItemType.ITEMTYPE_INDEX_TITLE) {
            IndexDataBean indexDataBean = (IndexDataBean) item;
            helper.setText(R.id.tv_item_title, indexDataBean.getClassifyName());
        }
    }
}
